package com.gljx.web.service.impl;

import com.gljx.web.Entity.SubjectThreeResultentry;
import com.gljx.web.Entity.User;
import com.gljx.web.dao.SubjectThreeResultentryMapper;
import com.gljx.web.service.CustomLogService;
import com.gljx.web.service.SubjectThreeResultentryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SubjectThreeResultentryServiceImpl implements SubjectThreeResultentryService {
	@Autowired
	private SubjectThreeResultentryMapper subjectThreeResultentryMapper;

	@Autowired
	private CustomLogService customLogService;
	@Override
	public List<SubjectThreeResultentry> selSubjectThreeResultentryByParentId(String parentid, String studentName,String cfexmaresult) {
		// TODO Auto-generated method stub
		return subjectThreeResultentryMapper.selSubjectThreeResultentryByParentId(parentid, studentName,cfexmaresult);
	}

	@Override
	public int deleteSubjectThreeResultentryByParentid(String parentid, User user,String fbizdate,String fnumber) {
		// TODO Auto-generated method stub
		if(user != null){
			//根据父类id查找子类信息
			List<SubjectThreeResultentry> subjectThreeResultentries =subjectThreeResultentryMapper.selSubjectThreeResultentryByParentId(parentid,null,null);
			for (int i = 0; i <subjectThreeResultentries.size() ; i++) {
				//添加学员的服务日志
				customLogService.addLog("考试管理", "删除了学员:"+subjectThreeResultentries.get(i).getCfstudentno()+subjectThreeResultentries.get(i).getStudentName()
						+",科目三考试结果登记!申请车型:"+subjectThreeResultentries.get(i).getCfsqzjcx()+",考试日期:"+fbizdate+",单据编号:"+fnumber, subjectThreeResultentries.get(i).getCfstudentid(), user.getFid());
			}
		}
		return subjectThreeResultentryMapper.deleteByParentId(parentid);
	}

}
